home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc A) / Acorn User China CD-ROM (UK) (Disc A).bin / DEMON / DEVELOPER / NETCONF0.ARC / !NetConfig_Resources_NetSlip < prev    next >
Encoding:
Text File  |  1995-08-09  |  9.5 KB  |  343 lines

  1. #slipdial
  2. #--------------------------------------------------------------------
  3. # Script for calling {{net_provider_name}}
  4. #
  5. # Credits: original               R.W. Orwin 1994 (rob@wong.demon.co.uk)
  6. #          sprites                James Woodman   (woody@bacchus.demon.co.uk)
  7. #          new version            Alan Fitch      (alan@cycle.demon.co.uk)
  8. #          mercury improvements   Mike James      (mike@hamble.demon.co.uk)
  9. #          improved setting up    Doug Macready   (dougmac@newquay.zynet.co.uk)
  10. #       Adapted for NetConfig  Colin Hogben    (colin@nyphot.demon.co.uk)
  11.  
  12. call initMain
  13. call configure
  14. call setserial
  15. call makemenus
  16.  
  17. #
  18. # main loop
  19. #
  20.  
  21. :loop
  22. message /close
  23. wait /event
  24. goto loop
  25. exit
  26.  
  27. # end of program
  28. #--------------------------------------------------------------------
  29.                 
  30. #====================================================================
  31. # SUBROUTINES
  32. #====================================================================
  33.  
  34. # dial number 1 from the configuration file
  35. :dial1
  36. set nRetries 50
  37. set phonenum %phonenum1
  38. if (?ne %phonenum1 %nopredialnum) set phonenum %predial%phonenum1
  39. goto dodial             
  40.  
  41. # dial number 2 from the configuration file
  42. :dial2
  43. set nRetries 50
  44. set phonenum %phonenum2
  45. if (?ne %phonenum2 %nopredialnum) set phonenum %predial%phonenum2
  46. goto dodial             
  47.  
  48. # dial number 3 from the configuration file
  49. :dial3
  50. set nRetries 50
  51. set phonenum %phonenum3
  52. if (?ne %phonenum3 %nopredialnum) set phonenum %predial%phonenum3
  53. goto dodial             
  54.  
  55. # dial the number defined as local
  56. :diallocal
  57. set nRetries 50
  58. set phonenum %localnumber
  59. if (?ne %localnumber %nopredialnum) set phonenum %predial%localnumber
  60. goto dodial             
  61.  
  62. #-----------------------------------------------------------
  63. # Subroutine: List
  64. # Calls a list of phone numbers, specified below in the 
  65. # variable 'phonenum'.  Returns via subroutine dodial.
  66. # nRetries is the number of times SlipDial retries the number 
  67. # if it is busy.
  68. # The number of retries is reduced compared to the other 
  69. # menu items (which dial only one PoP) as the intention is to 
  70. # to work through the list of numbers reasonably quickly.
  71. #-----------------------------------------------------------
  72.  
  73. :List
  74. set nRetries 5
  75. set phonenum %phonenum1
  76. if (?ne %phonenum1 %nopredialnum) set phonenum %predial%phonenum1
  77. if (?ne %phonenum2 %nopredialnum) set phonenum "%phonenum %predial"
  78. set phonenum "%phonenum%phonenum2"
  79. if (?ne %phonenum3 %nopredialnum) set phonenum "%phonenum %predial"
  80. set phonenum "%phonenum%phonenum3"
  81. goto dodial
  82.  
  83. #-----------------------------------------------------------
  84. # Subroutine: dodial
  85. # Note: has multiple entry points from "goto" statements
  86. # above.  However it finally returns to the main waiting
  87. # loop.
  88. #-----------------------------------------------------------
  89.  
  90. :dodial               
  91.  
  92. #
  93. # kill newsbase and ttfn if they are running, and were started from SlipDial
  94. #
  95. # Note that if they weren't started by SlipDial, SlipDial knows nothing
  96. # about them and will start another copy even if they are already running.
  97. #
  98.  
  99. task /kill="Newsbase"
  100. task /kill="TTFN"
  101.  
  102. # Claim the device driver
  103.  
  104. if (!claim 3) return 0
  105.  
  106. # initialise modem
  107.  
  108. if (! init) goto no_init
  109.  
  110. # Do we have a password?  If not then prompt for it.
  111. if (?ne "%password" "") goto havepass
  112. :getpass
  113.   input /prompt="Password:" /hide password
  114.   if (?eq "%password" "") goto getpass
  115. #endif
  116. :havepass
  117.  
  118. # dial the number, return to main menu if failed.
  119.  
  120. retry %nRetries 15
  121. if (!dial {{pulse}} /nodial=5 /nocar=3 /busy=3 %phonenum) return 0
  122.  
  123. #
  124. # arrive here if dial succeeded
  125. # get username/password prompts to authenticate self to server.
  126. # after each prompt, return to main menu if failed.
  127. #
  128.  
  129. @if net_slip_login_file$>""
  130. @include net_respath$+net_slip_login_file$
  131. @else
  132. if (!wait /del=50 {{net_login_prompt}}) goto no_login
  133. send %nodename
  134.  
  135. if (!wait /del=20 {{net_password_prompt}}) goto no_password
  136. send %password
  137.  
  138. @if net_protocol_prompt$>""
  139. if (!wait /del=50 {{net_protocol_prompt}}) goto no_protocol
  140. send {{net_protocol_reply}}
  141.  
  142. @endif
  143. @if net_startup_prompt$>""
  144. message /capture /end="{{net_startup_prompt}}" /maxlines=7 /centre
  145. @if net_fixed_ip$=""
  146. ipget {{net_ip_prefix}}
  147. @endif
  148. if (!wait /del=30 {{net_startup_prompt}}) goto no_start
  149.  
  150. @endif
  151. pause 5
  152. @endif
  153.  
  154. @if net_fixed_ip$=""
  155. make slipdial:Domain <TCPIP$Dir>.Domain
  156. oscli "SetType <TCPIP$Dir>.Domain Text"
  157. oscli "Set TCPIP$String$ip_addr %ipaddress"
  158. @endif
  159. task /name="TCP/IP" <TCPIP2$dir>.!Run
  160.  
  161. # watch out for carrier detect to go low
  162.  
  163. alarm /dcd "goto good_finish"
  164. :loop2
  165. wait /event
  166. goto loop2
  167.  
  168. #
  169. # Call has been finished successfully, so release the port
  170. #
  171.  
  172. :good_finish
  173. task /kill="TCP/IP"
  174. message /close
  175. message "Call finished successfully" /centre
  176. release
  177.  
  178. # now pause for 2 seconds to allow RISC OS to sort out the display.
  179.  
  180. pause 2
  181.  
  182. #
  183. # Start up TTFN and Newsbase.
  184. #
  185.  
  186. if (!?task TTFN) task /name="TTFN" <TTFN$Dir>.!Run
  187. if (!?task NewsBase) task /name="Newsbase" <NewsBase$Dir>.!Run
  188. return 1
  189.  
  190. #
  191. # Call failed in some way
  192. #
  193.  
  194. :no_dsr
  195. message/wait "Modem not ready - DSR line is not set" "(Please close this window to continue)" /centre
  196. goto bad_finish
  197.  
  198. :no_cts
  199. message/wait "Modem not ready - CTS line is not set" "(Please close this window to continue)" /centre
  200. goto bad_finish
  201.  
  202. :no_init
  203. message/wait "Modem initialisation failed" "(Please close this window to continue)" /centre
  204. goto bad_finish
  205.  
  206. :no_login
  207. message "Call failed - timeout waiting for login prompt" /centre
  208. goto bad_finish
  209.  
  210. :no_password
  211. message "Call failed - timeout waiting for password prompt" /centre
  212. goto bad_finish
  213.  
  214. :no_protocol
  215. message "Call failed - timeout waiting for protocol prompt" /centre
  216. goto bad_finish
  217.  
  218. :no_start
  219. message "Call failed - timeout waiting for session start" /centre
  220. goto bad_finish
  221.  
  222. :bad_finish
  223. pause 1
  224. release
  225. reinit
  226. return 0
  227.  
  228. #-----------------------------------------------------------
  229. # Subroutine: makemenus
  230. # Defines the menus for dialling etc.  Note the length of 
  231. # all the names must be less than 255 characters total, as 
  232. # must the length of all the commands.
  233. #-----------------------------------------------------------
  234.  
  235. :makemenus
  236. @if net_pop3$>""
  237. menu "%name1:call dial1" "%name2:call dial2" "%name3: call dial3" "List:call List"
  238. @elseif net_pop2$>""
  239. menu "%name1:call dial1" "%name2:call dial2" "List:call List"
  240. @else
  241. menu "%name1:call dial1"
  242. @endif
  243. menu /icon="Local"   "Local call:call diallocal" 
  244. return 1
  245.  
  246. #-----------------------------------------------------------
  247. # Subroutine: setserial
  248. # Set Serial Port/Driver Parameters
  249. #-----------------------------------------------------------
  250.  
  251. :setserial
  252. driver %driver
  253. port %wport %prtnum
  254. speed %speed
  255. return 1
  256.  
  257. #-----------------------------------------------------------
  258. # Subroutine: setup1
  259. # Called to setup defaults if no configuration file present.
  260. #-----------------------------------------------------------
  261.  
  262. :setup1
  263. input/prompt="Enter Serial Block Driver Name         : " wport
  264. input/prompt="Enter Serial Port Number (if relevant) : " prtnum
  265. input/prompt="Enter Your Modem->Computer Speed (bps) : " speed
  266. input/prompt="Enter Your Account name                : " nodename
  267. input/prompt="Enter Your Password                    : " password
  268. input/prompt="Enter Your Modem Driver Name (e.g. USR): " driver
  269. input/prompt="Enter Dial prefix e.g. Mercury PIN     : " predial
  270. input/prompt="Enter NAME of main number e.g. London  : " name1
  271. input/prompt="Enter NUMBER of main number e.g. 01813384848 : " phonenum1  
  272. input/prompt="Enter NAME of 2nd number               : " name2
  273. input/prompt="Enter NUMBER  2nd number               : " phonenum2
  274. input/prompt="Enter NAME of 3rd number               : " name3
  275. input/prompt="Enter NUMBER of 3rd number             : " phonenum3
  276. input/prompt="Enter nearest NUMBER, e.g. 01813384848 : " localnumber
  277. input/prompt="Enter number to which dial prefix does not apply, e.g. 01813384848 : " nopredialnum
  278. :saveconfig
  279. set filename {?file/expand slipdial:NetConfg}
  280. open/id=conf/write %filename
  281. write/id=conf %wport
  282. write/id=conf %prtnum
  283. write/id=conf %speed
  284. write/id=conf %nodename
  285. write/id=conf %password
  286. write/id=conf %driver
  287. write/id=conf %predial
  288. write/id=conf %name1
  289. write/id=conf %phonenum1
  290. write/id=conf %name2
  291. write/id=conf %phonenum2
  292. write/id=conf %name3
  293. write/id=conf %phonenum3 
  294. write/id=conf %localnumber
  295. write/id=conf %nopredialnum
  296. close/id=conf
  297. return 1
  298.  
  299. #-----------------------------------------------------------
  300. # Subroutine: configure
  301. # This loads password config from file or prompts for data 
  302. # to create file.
  303. #-----------------------------------------------------------
  304.  
  305. :configure
  306. set filename {?file/expand slipdial:NetConfg}
  307. if (!?file %filename) call setup1
  308. open/read/id=conf/error="return" %filename
  309. read/id=conf/eof="goto closeconf" wport
  310. read/id=conf/eof="goto closeconf" prtnum
  311. read/id=conf/eof="goto closeconf" speed
  312. read/id=conf/eof="goto closeconf" nodename
  313. read/id=conf/eof="goto closeconf" password
  314. read/id=conf/eof="goto closeconf" driver
  315. read/id=conf/eof="goto closeconf" predial
  316. read/id=conf/eof="goto closeconf" name1
  317. read/id=conf/eof="goto closeconf" phonenum1
  318. read/id=conf/eof="goto closeconf" name2
  319. read/id=conf/eof="goto closeconf" phonenum2
  320. read/id=conf/eof="goto closeconf" name3    
  321. read/id=conf/eof="goto closeconf" phonenum3
  322. read/id=conf/eof="goto closeconf" localnumber
  323. read/id=conf/eof="goto closeconf" nopredialnum
  324. :closeconf
  325. close/id=conf
  326. return
  327.  
  328. #-----------------------------------------------------------
  329. # Subroutine: initMain
  330. # General initialisation.
  331. #-----------------------------------------------------------
  332.  
  333. :initMain                
  334.  
  335. # remove comment from following line for tracing
  336.  
  337. #trace "SlipDial:logoutput"
  338. debug 3
  339. icon /id="Local" /action="call diallocal" loc
  340. return 1
  341.  
  342. # End of file
  343.